<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" import="java.util.*" %>
<%@  page import   =   "java.text.*"   %>
<%@  page import   =   "java.sql.*"   %>
<%
String context = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+context+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <script src="<%=request.getContextPath()%>/js/ajax1.js" language="javascript"></script>
  <script src="<%=request.getContextPath()%>/js/mootools-1.2.1-core-yc.js" language="javascript"></script>
  <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<%= context%>/js/lib/prototype.js"></script>
    <script type="text/javascript" src="<%= context%>/js/lib/autocomplete.js"></script>
    <link rel="stylesheet" type="text/css" href="<%= context%>/css/autocomplete/autocomplete.css" /> 
    
    <script language="javascript">
        var guid="";
        function MM(){
            var url="<%= request.getContextPath()%>/Chaxun";
            var myAjax = new Ajax1(url,{method:'POST',onComplete:function(){
                 var a=this.req.responseText;
                 var xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); 
                 xmlDoc.loadXML(a);
                 x=xmlDoc.documentElement.childNodes;
                 if(x!=null&&x.length>0){
                     var table_str="<table border='1'><tr><th>rec_guid</th><th>ani</th><th>dnis</th></tr>";
                     for (i=0;i<x.length;i++){
                         var rec_guid=xmlDoc.getElementsByTagName("rec_guid")[i].childNodes[0].nodeValue;
                         rec_guid=rec_guid.replace(/\ +/g,"");
                         rec_guid=rec_guid.replace(/[ ]/g,"");    
                         rec_guid=rec_guid.replace(/[\r\n]/g,"");
                         var rec_guid1="'"+rec_guid+"'";
                         var ani=xmlDoc.getElementsByTagName("ani")[i].childNodes[0].nodeValue;
                         var dnis=xmlDoc.getElementsByTagName("dnis")[i].childNodes[0].nodeValue; 
                         table_str=table_str+'<tr onclick="getguid('+rec_guid1+')"><td>'+rec_guid+'</td><td>'+ani+'</td><td>'+dnis+'</td></tr>';
                     } 
                     table_str=table_str+"</table>";
                 }
                 document.getElementById("test").innerHTML=table_str;   
                              
            }});       
        }
        
        function MM1(){
            var url="<%= request.getContextPath()%>/queryrec?rec_guid="+guid;
            var myAjax = new Ajax1(url,{method:'POST',onComplete:function(){
                 var a=this.req.responseText;
                 var xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); 
                 xmlDoc.loadXML(a);
                 var documentpath=xmlDoc.getElementsByTagName("documentpath")[0].childNodes[0].nodeValue;
                 alert(documentpath);
                              
            }});  
        }
        function getguid(a){
           guid=a;
        }
        
        function btsOpen(serverName,endPoint,userName,password,type){
            if(BTSClient!=null){
               BTSClient.open(serverName,endPoint,userName,password,type);
               return true;
            }else{
               return false;
            }
        }
        
        function btsGetFile(remoteFileName,localFileName){
            if(BTSClient!=null){
               BTSClient.GetFile(remoteFileName,localFileName);
               return true;
            }else{
               return false;
            }
        
        }
        
        function btsClose(){
             if(BTSClient!=null){
               BTSClient.Close();
               return true;
            }else{
               return false;
            }
        
        }
        
        function convertToPlayableFile3(fileName,nFileType,targetFileName){
            if(waveConverter!=null){
               waveConverter.ConvertToPlayableFile3(fileName,nFileType,targetFileName);
               return true;
            }else{
               return false;
            }
        }
    </script>
  </head>
  
  <body>
       <input type="button" value="查询" onclick="MM()">     <input type="button" value="听录音" onclick="MM1()">
       <br>
       <br>
       <br>
       <br>
       <div id="test"></div>

  </body>
</html>
